/*******************************************************************************
	   Purpose: Combine the emissions data created using different imputation rules
   ****************************************************************************/

set more off
clear all
pause on

use "$IMPUTATION_DATA_OUT/PlantPeriodPMMassRule0.dta"
keep gpcb_id treatmentstatus period ind_period_mass_val_rule0
rename ind_period_mass_val_rule0 pm_mass_val_0

merge 1:1 gpcb_id treatmentstatus period using "$IMPUTATION_DATA_OUT/PlantPeriodPMMassRuleA.dta"
rename ind_period_mass_val_rule0 pm_mass_val_A
keep gpcb_id treatmentstatus period pm_mass_val_0 pm_mass_val_A

merge 1:1 gpcb_id treatmentstatus period using "$IMPUTATION_DATA_OUT/PlantPeriodPMMassRuleB.dta"
rename ind_period_mass_val_rule0 pm_mass_val_B
keep gpcb_id treatmentstatus period pm_mass_val_0 pm_mass_val_A pm_mass_val_B

rename period period_num
label var period_num "Compliance period number"

label var pm_mass_val_0 "Plant-period Validated Mass Emissions (kg) - Rule 0"
label var pm_mass_val_A "Plant-period Validated Mass Emissions (kg) - Rule A"
label var pm_mass_val_B "Plant-period Validated Mass Emissions (kg) - Rule B"

*** 292 plants x 10 period = 2,920 observations
save "$EMISSIONS_DATA_OUT/pm_mass_plant-period.dta", replace
